<template>
    <el-dialog title="Stu" :visible.sync="isShow">
        <el-form :model="form">
            <el-form-item label="设备名称"  :label-width="formLabelWidth">
                <el-input :disabled="myshow" v-model="form.equipmentname" placeholder="设备名称" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="设备类型" :label-width="formLabelWidth">
                <el-input :disabled="myshow" v-model="form.equipmenttype" placeholder="设备类型" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="运行状态" :label-width="formLabelWidth">
                <el-input :disabled="myshow" v-model="form.alarmtype" placeholder="运行状态"></el-input>
            </el-form-item>
            <el-form-item label="经度" :label-width="formLabelWidth">
                <el-input :disabled="myshow" v-model="form.longtitude" placeholder="经度"></el-input>
            </el-form-item>
            <el-form-item label="维度" :label-width="formLabelWidth">
                <el-input :disabled="myshow" v-model="form.attitude" placeholder="纬度"></el-input>
            </el-form-item>
            <el-form-item label="位置" :label-width="formLabelWidth">
                <el-input :disabled="myshow" v-model="form.address" placeholder="位置"></el-input>
            </el-form-item>
            <el-form-item label="连接方式" :label-width="formLabelWidth">
                <el-input :disabled="myshow" v-model="form.linktype" placeholder="连接方式"></el-input>
            </el-form-item>
            <el-form-item label="连接端口" :label-width="formLabelWidth">
                <el-input :disabled="myshow" v-model="form.maintainport" placeholder="连接端口"></el-input>
            </el-form-item>
            <el-form-item label="上次维护ID" :label-width="formLabelWidth">
                <el-input :disabled="myshow" v-model="form.lastmaintainuid" placeholder="上次维护ID"></el-input>
            </el-form-item>
          <el-form-item label="上次维护日期">
            <el-col :span="11">
                <el-date-picker
                    :disabled="myshow"
                    v-model="form.lastmaintaintime"
                    type="datetime" style="width: 100%;"
                    placeholder="上次维护日期"
                    format="yyyy-MM-dd hh:mm:ss"
                    value-format='yyyy-MM-dd[T]hh:mm:ss'
                    align="right"
                    :picker-options="pickerOptions">
                </el-date-picker>
            </el-col>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFormVisible">取 消</el-button>
            <el-button type="primary" @click="commit">确 定</el-button>
        </div>
    </el-dialog>
</template>

<script>
    export default {
        props: ['isShow','editInfo','hoverEquipmentInfo'],
        data() {
            return {
                pickerOptions: {
                shortcuts: [{
                  text: '今天',
                  onClick(picker) {
                    picker.$emit('pick', new Date());
                  }
                }, {
                  text: '昨天',
                  onClick(picker) {
                    const date = new Date();
                    date.setTime(date.getTime() - 3600 * 1000 * 24);
                    picker.$emit('pick', date);
                  }
                }, {
                  text: '一周前',
                  onClick(picker) {
                    const date = new Date();
                    date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                    picker.$emit('pick', date);
                  }
                }]
              },
                form: {},
                formLabelWidth: '100px',
                myshow: false
            }
        },
        methods:{
            commit() {
                if (this.editInfo){
                    this.$emit('update1',this.form);
                }
                this.close()
            },
            dialogFormVisible(){
                this.close()
            },
            close() {
                this.$emit('close')
            }
        },
        mounted() {
            // 父组件传参告诉子组件我需要你可以让用户操作数据
            if(this.editInfo) {this.myshow = false}
            else {this.myshow = true}
            this.form = JSON.parse(JSON.stringify(this.hoverEquipmentInfo))
            console.log(this.form)
        }
    }
</script>

<style scoped>

</style>